<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Ref
 *
 * @author Moon
 */
class Shipping_Ref extends CUniqueValidator{
    //put your code here

    public $date = '';

    public function validateAttribute($model,$attribute)
    {
        $_date = $this->date;
        $date = $_date = explode("/", $model->$_date);
        $in_date = date('Y',mktime(0,0,0,$date[1],$date[0],$date[2]));
        $criteria = new CDbCriteria;
        $criteria->condition = "from_unixtime(in_date,'%Y')=:year";
        $criteria->params = array(':year'=>$in_date);
        $this->criteria = $criteria;
        return parent::validateAttribute($model, $attribute);
    }
}
?>
